/*
 * Trilogy instant messaging system
 * Nathan Reitz, Aaron Mertz, Dave Clark
 * 11/14/2007
*/
package edu.psu.ist.ist311.trilogyIM;

import javax.swing.*;

public class LoginScreen extends JPanel{
	
	//the graphical elements of the panel
	JTextField userField, passField;
	JLabel userLabel, passLabel;
	JButton login, cancel;
	BuddyWindow parentWindow;
	
	//constructor
	public LoginScreen(BuddyWindow parent){
		super();
		
		//remembers the parent for action handling purposes
		parentWindow = parent;
		
		//draws everything
		createGui();
	}
	
	public void createGui() {	//used to create the frame and look
        
		//creates the interactive elements
		userField = new JTextField(22);
		passField = new JTextField(22);
		userLabel = new JLabel("Username: ");
		passLabel = new JLabel("Password: ");
		
		//creates the buttons and adds action listeners to each
		login = new JButton("Login");
		login.addActionListener(parentWindow);
		cancel = new JButton("Cancel");
		cancel.addActionListener(parentWindow);
		
		//adds to panel
		this.add(userLabel);
		this.add(userField);
		this.add(passLabel);
		this.add(passField);
		this.add(login);
		this.add(cancel);
		
        this.setVisible(true);
      
	}
	
	//returns the contents of the username field
	public String getUsername(){
		return userField.getText();
	}
	
	//	returns the contents of the password field
	public String getPassword(){
		return passField.getText();
	}
}
